<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"jiangjiang.github.io","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false,"avatar":"https://wx2.sinaimg.cn/mw690/43ec3da8gy1gl5td0mhs5j20qd0qd40b.jpg","url":null,"rounded":false,"rotated":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="从Hello World 开始HelloWorld.java 12345public class HelloWorld &amp;#123;    public static void main(String[] args) &amp;#123;        System.out.println(&quot;Hello World!&quot;);    &amp;#125;&amp;#125; 这个文档撰写时有几点必须注意：">
<meta property="og:type" content="article">
<meta property="og:title" content="ch1 JDK 和 JRE">
<meta property="og:url" content="https://jiangjiang.github.io/jiang83.github.io/2020/11/30/java-01-JDK-JRE/index.html">
<meta property="og:site_name" content="Grinding">
<meta property="og:description" content="从Hello World 开始HelloWorld.java 12345public class HelloWorld &amp;#123;    public static void main(String[] args) &amp;#123;        System.out.println(&quot;Hello World!&quot;);    &amp;#125;&amp;#125; 这个文档撰写时有几点必须注意：">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2020-11-30T01:11:30.000Z">
<meta property="article:modified_time" content="2020-11-30T03:35:04.792Z">
<meta property="article:author" content="Jiang Jiang">
<meta property="article:tag" content="java">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://jiangjiang.github.io/jiang83.github.io/2020/11/30/java-01-JDK-JRE/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'en'
  };
</script>

  <title>ch1 JDK 和 JRE | Grinding</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Toggle navigation bar">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Grinding</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Insist on output</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>Home</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>Archives</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
    <link itemprop="mainEntityOfPage" href="https://jiangjiang.github.io/jiang83.github.io/2020/11/30/java-01-JDK-JRE/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="Jiang Jiang">
      <meta itemprop="description" content="Jiang Jiang's learning notes">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Grinding">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          ch1 JDK 和 JRE
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>
              

              <time title="Created: 2020-11-30 09:11:30 / Modified: 11:35:04" itemprop="dateCreated datePublished" datetime="2020-11-30T09:11:30+08:00">2020-11-30</time>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h3 id="从Hello-World-开始"><a href="#从Hello-World-开始" class="headerlink" title="从Hello World 开始"></a>从Hello World 开始</h3><p>HelloWorld.java</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">public class HelloWorld &#123;</span><br><span class="line">    public static void main(String[] args) &#123;</span><br><span class="line">        System.out.println(&quot;Hello World!&quot;);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>这个文档撰写时有几点必须注意：</p>
<ul>
<li>扩展名是.java：</li>
<li>主文件名与类名称必须相同。类名称是指class关键词后的名称：<br> 范例主文件名就是HelloWorld这个名称，这个名称必须与HelloWorld.java的主文件名（HelloWorld）相同。</li>
<li>注意每个字母大小写。Java程序区分字母大小写，System与system对Java程序来说是不同的名称。</li>
<li>空格只能是半角空格符或Tab字符</li>
</ul>
<h3 id="1-定义类"><a href="#1-定义类" class="headerlink" title="1.定义类"></a>1.定义类</h3><p>class是用来定义类的关键词，之后接上类名称（HelloWorld）。<br>Java程序规定，所有程序代码都要定义在“类”中。<br><strong>public关键词</strong>，表示HelloWorld类是公开类，一个.java文件可定义多个类，但是只能有一个公开类，而且主文件名必须与公开类名称相同。</p>
<h3 id="2．定义区块（Block）"><a href="#2．定义区块（Block）" class="headerlink" title="2．定义区块（Block）"></a>2．定义区块（Block）</h3><p>在程序中使用大括号“{”与“}”定义区块，大括号两两成对，目的在于区别程序代码范围。例如，<br>程序中HelloWorld类的区块包括了main()方法（Method）<br>而main()方法的区块包括了一句显示信息的程序代码</p>
<h3 id="3．定义main-方法"><a href="#3．定义main-方法" class="headerlink" title="3．定义main()方法"></a>3．定义main()方法</h3><p>程序执行的起点就是 <strong>程序进入点（Entrypoint）</strong>，Java程序执行的起点是main()方法。<br>main()方法是 <strong>public成员</strong>，表示可以被JVM公开执行，<br> <strong>static</strong> 表示JVM不用生成类实例就可以调用，<br> Java程序执行过程的错误，都是以例外方式处理，所以main()不用传回值，声明为void即可，<br> String[] args可以在执行程序时，取得用户指定的命令行自变量。</p>
<h3 id="4．撰写语句（Statement）"><a href="#4．撰写语句（Statement）" class="headerlink" title="4．撰写语句（Statement）"></a>4．撰写语句（Statement）</h3><p>语句是程序语言中的一行指令，简单地说，就是程序语言中的“一句话”。</p>
<blockquote>
<p>System.out.println(“Hello World!”);</p>
</blockquote>
<p>每句代码的结束要用分号（;）<br>其实使用了java.lang包（package）中System类的public static成员out。（out参考至PrintStream实例）</p>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/java/" rel="tag"># java</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2020/11/29/world-outlook/" rel="prev" title="周三晚上吃饭随想">
      <i class="fa fa-chevron-left"></i> 周三晚上吃饭随想
    </a></div>
      <div class="post-nav-item">
    <a href="/2020/11/30/java-02-Path/" rel="next" title="java_02_Path">
      java_02_Path <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          Table of Contents
        </li>
        <li class="sidebar-nav-overview">
          Overview
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BB%8EHello-World-%E5%BC%80%E5%A7%8B"><span class="nav-number">1.</span> <span class="nav-text">从Hello World 开始</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-%E5%AE%9A%E4%B9%89%E7%B1%BB"><span class="nav-number">2.</span> <span class="nav-text">1.定义类</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%EF%BC%8E%E5%AE%9A%E4%B9%89%E5%8C%BA%E5%9D%97%EF%BC%88Block%EF%BC%89"><span class="nav-number">3.</span> <span class="nav-text">2．定义区块（Block）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3%EF%BC%8E%E5%AE%9A%E4%B9%89main-%E6%96%B9%E6%B3%95"><span class="nav-number">4.</span> <span class="nav-text">3．定义main()方法</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4%EF%BC%8E%E6%92%B0%E5%86%99%E8%AF%AD%E5%8F%A5%EF%BC%88Statement%EF%BC%89"><span class="nav-number">5.</span> <span class="nav-text">4．撰写语句（Statement）</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">Jiang Jiang</p>
  <div class="site-description" itemprop="description">Jiang Jiang's learning notes</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">12</span>
          <span class="site-state-item-name">posts</span>
        </a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">4</span>
        <span class="site-state-item-name">tags</span>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/JiangJiang" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;JiangJiang" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i></a>
      </span>
      <span class="links-of-author-item">
        <a href="https://weibo.com/201273989" title="Weibo → https:&#x2F;&#x2F;weibo.com&#x2F;201273989" rel="noopener" target="_blank"><i class="fab fa-weibo fa-fw"></i></a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Jiang Jiang</span>
</div>
  <div class="powered-by">Powered by <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a>
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
